package com.immediatus.graphics.util;

import android.graphics.Bitmap;
import com.immediatus.graphics.texture.Texture;

public enum BitmapTextureFormat{
    RGBA_8888(Bitmap.Config.ARGB_8888, Texture.PixelFormat.RGBA_8888),
    RGB_565(Bitmap.Config.RGB_565, Texture.PixelFormat.RGB_565),
    RGBA_4444(Bitmap.Config.ARGB_4444, Texture.PixelFormat.RGBA_4444),
    A_8(Bitmap.Config.ALPHA_8, Texture.PixelFormat.A_8);

    private final Bitmap.Config _bitmapConfig;
    private final Texture.PixelFormat _pixelFormat;

    private BitmapTextureFormat(final Bitmap.Config bitmapConfig_, final Texture.PixelFormat pixelFormat_){
        this._bitmapConfig = bitmapConfig_;
        this._pixelFormat = pixelFormat_;
    }

    public static BitmapTextureFormat fromPixelFormat(final Texture.PixelFormat pixelFormat_){
        switch (pixelFormat_){
            case RGBA_8888:
                return RGBA_8888;
            case RGBA_4444:
                return RGBA_4444;
            case RGB_565:
                return RGB_565;
            case A_8:
                return A_8;
            default:
                throw new IllegalArgumentException(
                        "Unsupported " + Texture.PixelFormat.class.getName() + ": '" + pixelFormat_ + "'.");
        }
    }

    public Bitmap.Config getBitmapConfig(){
        return this._bitmapConfig;
    }

    public Texture.PixelFormat getPixelFormat(){
        return this._pixelFormat;
    }
}
